﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

namespace ICMS
{
    /// <summary>
    /// 网站全局异步调用接口
    /// </summary>
    [ServiceContract(Namespace = "")]
    public interface IAjaxService
    {
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>用户编号</returns>
        [OperationContract, WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        int Login(string username, string password);
        /// <summary>
        /// 用户投票
        /// </summary>
        /// <param name="votingId">投票编号</param>
        /// <param name="optionId">选项编号</param>
        /// <param name="userId">用户编号</param>
        /// <returns>是否投票成功 0不成功 1成功</returns>
        [OperationContract, WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        string Vote(int votingId, int optionId, int userId);
        /// <summary>
        /// 用户发表评论
        /// </summary>
        /// <param name="docId">评论的文章编号</param>
        /// <param name="userId">用户编号</param>
        /// <param name="content">评论的内容</param>
        /// <returns>是否评论成功 0不成功 1成功</returns>
        [OperationContract, WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        string Reply(int docId, int userId, string content);
        /// <summary>
        /// 用户推荐
        /// </summary>
        /// <param name="docId">推荐的文章编号</param>
        /// <param name="userId">用户编号</param>
        /// <returns>是否推荐成功 0不成功 1成功</returns>
        [OperationContract, WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        string Recommend(int docId, int userId);
    }
}
